using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using MULENetworking;



namespace MainGame
{
    [Serializable]
    public class ClientMapSquare: IMapSquare
    {
        protected Point location;
        protected Rectangle rectangleLocation;
        protected string type;
        protected int numMountains;
        protected IPlayer owner;  
        protected string mule; 
        protected int etnum;
        protected Random rand = new Random();
        protected Bitmap energy, energy1, food, house, smithore1, smithore2, smithore3, muleenergy, mulefood, mulesmithore, mulecrystite;

       

        public ClientMapSquare() //location, resources on square, number of mountains, type of mule
        {      
        }



#region properties
        public Point Position
        {
            
            get { return location; }
            set { location = value; }

        }

        public int NumMountains
        {
            get { return numMountains; }
        }

        public string Type
        {
            get { return type; }
            set { type = value; }
        }

        public int Mountains
        {
            get{return numMountains;}
            set { numMountains = value; }
        }


        public IPlayer Owner
        {
            get { return owner; }
            set { owner = value; }
        }


        public string Mule
        {
            get { return mule; }
            set { mule = value; }
        }
#endregion



        public void Initialize()
        {
            etnum = rand.Next(0, 2);
            energy = new Bitmap("energy1.bmp");
            energy1 = new Bitmap("energy2.bmp");
            smithore1 = new Bitmap("smithore1.bmp");
            smithore2 = new Bitmap("smithore2.bmp");
            smithore3 = new Bitmap("smithore3.bmp");
            house = new Bitmap("base.bmp");
            food = new Bitmap("food.bmp");
            rectangleLocation = new Rectangle(location, new Size(98, 98)); 
        }

        public void Draw(Graphics g) 
        {

            if (type == "energy")
            {
                if (etnum == 0)
                    g.DrawImage(energy, location.X, location.Y, 100, 100);
                else
                    g.DrawImage(energy1, location.X, location.Y, 100, 100);
            }
            else if (type == "food")
                g.DrawImage(food, location.X, location.Y, 100, 100);
            else if (type == "store")
                g.DrawImage(house, 400, 200, 100, 100);
            else if (type == "smithore")
            {
                switch (numMountains)
                {
                    case 1:
                        g.DrawImage(smithore1, location.X, location.Y, 100, 100);
                        break;
                    case 2:
                        g.DrawImage(smithore2, location.X, location.Y, 100, 100);
                        break;
                    case 3:
                        g.DrawImage(smithore3, location.X, location.Y, 100, 100);
                        break;
                }
            }



            if (mule != null)
            {
                if (mule == "energy")
                    g.DrawImageUnscaled(new Bitmap("muleenergy.bmp"), location);
                else if (mule == "food")
                    g.DrawImageUnscaled(new Bitmap("mulefood.bmp"), location);
                else if (mule == "smithore")
                    g.DrawImageUnscaled(new Bitmap("mulesmithore.bmp"), location);
                else if (mule == "crystite")
                    g.DrawImageUnscaled(new Bitmap("mulecrystite.bmp"), location);
            }

            if (owner != null)
            {
                g.DrawRectangle(new Pen(owner.color), rectangleLocation);  //changed location to rectangleLocation and made it an actual rectangle, not a point
            }
        }

    }
}
